﻿using System;
using System.Windows.Data;
using System.Windows.Media;

namespace Finance.UI.Utils
{
    public class CashAmountCurrencyConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (typeof(double).IsAssignableFrom(value.GetType()))
            {
                var amount = (double)value;
                return string.Format("{0:C2}", amount);
            }
            throw new ArgumentException("Invalid data type, type of double is required.");
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException("No need to convert back.");
        }
    }
}
